package com.simon.train.business.config;

import com.simon.train.common.interception.LogInterceptor;
import com.simon.train.common.interception.MemberInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

   @Resource
   LogInterceptor logInterceptor;

   @Resource
   MemberInterceptor memberInterceptor;

   @Override
   public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(logInterceptor)
               .addPathPatterns("/**");

      registry.addInterceptor(memberInterceptor)
              .addPathPatterns("/**")  //表明针对所有的请求接口都生效
              .excludePathPatterns( //这几个页面此时还没有登录 所以不需要拦截，因为也没有token可以获取
                      "/business/hello"
              );

   }
}
